﻿/*-----------funstep 覆盖easyui部分默认行为-----------------*/
$.fn.pagination.defaults = $.extend(true, {}, $.fn.pagination.defaults, {
    pageList: [1, 5, 10, 15, 20, 25, 30, 50, 100, 1000]
});

$.fn.datagrid.defaults = $.extend(true, {}, $.fn.datagrid.defaults, {
    fit: true,
    autoRowHeight: false,
    //fitColumns: true,
    pagination: true,
    rownumbers: true,
    striped: true,
    // singleSelect: true,
    pageList: $.fn.pagination.defaults.pageList,
    emptyMsg: '<i class="ion-information-circled" style="margin-right:5px;vertical-align:-2px;"></i>暂无数据'
});

 $.extend($.fn.validatebox.defaults, {
    tipPosition: 'bottom',
    missingMessage: '此为必填项'
});


$.fn.numberbox.defaults = $.extend(true, {}, $.fn.numberbox.defaults, {
    tipPosition: 'bottom',
    missingMessage: '此为必填项'
});
$.fn.textbox.defaults = $.extend(true, {}, $.fn.textbox.defaults, {
    tipPosition: 'bottom',
    missingMessage: '此为必填项'
});
$.fn.combobox.defaults = $.extend(true, {}, $.fn.combobox.defaults, {
    tipPosition: 'bottom',
    missingMessage: '此为必选项或必填项',
    rules: $.extend(true, $.fn.validatebox.defaults.rules, {
        belong: {
            validator: function (value, hander) {
                var $combobox = $(this).closest('.textbox').siblings('.easyui-combobox');
                var data = $combobox.combobox('getData');
                var matches = $.grep(data, function (item) {
                    return item.text === value;
                });
                return matches.length > 0;
            },
            message: '请选择下拉框中的值'
        },
        empty: {
            validator: function (value, hander) {
                return value !== hander[0];
            },
            message: '请选择下拉框中的值'
        }
    })
});
$.extend($.fn.validatebox.defaults.rules, {
    date: {
        validator: function (value, hander) {
            var valid = false;

            try {
                //var regExp = new RegExp(/^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/);
                //if (!regExp.test(value)) {
                //    return false;
                //}

                var tempDate = new Date(value);
                if (!isNaN(tempDate.getTime())) {
                    valid = true;
                }
            }
            catch (e) {
                ;
            }
            return valid;
        },
        message: '时间格式不正确'
    },
    phone: {
        validator: function (value) {
            return /^1\d{10}$/.test(value);
        },
        message: '手机号码格式不正确'
    }
});

$.extend($.fn.textbox.defaults.rules, $.fn.validatebox.defaults.rules);

$.fn.window.defaults = $.extend(true, {}, $.fn.window.defaults, {
    inline: true,
    collapsible: false,
    minimizable: false,
    maximizable: false,
    modal: true
    //handles: 'n,s',
    //resizable: false
});

$.fn.radiobutton.defaults = $.extend(true, {}, $.fn.radiobutton.defaults, {
    labelPosition: "after"
});


$.fn.datetimebox.defaults = $.extend(true, {}, $.fn.datetimebox.defaults, {
    formatter: function (date) {
        var datestr = funstep.dateFormat(date, "yyyy-MM-dd hh:mm:ss");
        return datestr;
    }
});

$.messager.defaults = $.extend(true, {}, $.messager.defaults, {
    closable: false,
    width: 450,
    minHeight:130
});